﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace LimaLims.Database.Migrations.Migrations
{
    /// <inheritdoc />
    public partial class updatetaskFactoryNumbe : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<string>(
                name: "FactoryNumbe",
                table: "ExperimentTask",
                type: "nvarchar(max)",
                nullable: true,
                comment: "出厂编号");

            migrationBuilder.CreateTable(
                name: "MessageContent",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false, comment: "Id主键"),
                    Title = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "标题"),
                    Content = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "内容"),
                    ParamId = table.Column<long>(type: "bigint", nullable: true, comment: "参数"),
                    Tag = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "业务标签"),
                    CreatedTime = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "创建时间"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "更新时间"),
                    CreatedUserId = table.Column<long>(type: "bigint", nullable: true, comment: "创建者Id"),
                    CreatedUserName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true, comment: "创建者名称"),
                    UpdatedUserId = table.Column<long>(type: "bigint", nullable: true, comment: "修改者Id"),
                    UpdatedUserName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true, comment: "修改者名称"),
                    ValidStatus = table.Column<bool>(type: "bit", nullable: false, comment: "有效性"),
                    Sort = table.Column<int>(type: "int", nullable: false, comment: "排序"),
                    TenantId = table.Column<long>(type: "bigint", nullable: true, comment: "租户id")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MessageContent", x => x.Id);
                },
                comment: "站内消息内容");

            migrationBuilder.CreateTable(
                name: "SysMessage",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false, comment: "Id主键"),
                    ReceiveUserId = table.Column<long>(type: "bigint", nullable: false, comment: "接收人ID"),
                    IsRead = table.Column<bool>(type: "bit", nullable: false, comment: "是否阅读"),
                    MessageContentId = table.Column<long>(type: "bigint", nullable: false, comment: "消息内容ID"),
                    CreatedTime = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "创建时间"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "更新时间"),
                    CreatedUserId = table.Column<long>(type: "bigint", nullable: true, comment: "创建者Id"),
                    CreatedUserName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true, comment: "创建者名称"),
                    UpdatedUserId = table.Column<long>(type: "bigint", nullable: true, comment: "修改者Id"),
                    UpdatedUserName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true, comment: "修改者名称"),
                    ValidStatus = table.Column<bool>(type: "bit", nullable: false, comment: "有效性"),
                    Sort = table.Column<int>(type: "int", nullable: false, comment: "排序"),
                    TenantId = table.Column<long>(type: "bigint", nullable: true, comment: "租户id")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysMessage", x => x.Id);
                    table.ForeignKey(
                        name: "FK_SysMessage_MessageContent_MessageContentId",
                        column: x => x.MessageContentId,
                        principalTable: "MessageContent",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "用户站内消息");

            migrationBuilder.UpdateData(
                table: "SysTenant",
                keyColumn: "Id",
                keyValue: 142307070918780L,
                column: "CreatedTime",
                value: new DateTime(2025, 1, 6, 20, 42, 3, 101, DateTimeKind.Local).AddTicks(2927));

            migrationBuilder.UpdateData(
                table: "SysUser",
                keyColumn: "Id",
                keyValue: 142307070910551L,
                column: "CreatedTime",
                value: new DateTime(2025, 1, 6, 20, 42, 3, 102, DateTimeKind.Local).AddTicks(2236));

            migrationBuilder.UpdateData(
                table: "Team",
                keyColumn: "Id",
                keyValue: 242307070910559L,
                column: "CreatedTime",
                value: new DateTime(2025, 1, 6, 20, 42, 3, 166, DateTimeKind.Local).AddTicks(9649));

            migrationBuilder.CreateIndex(
                name: "IX_SysMessage_MessageContentId",
                table: "SysMessage",
                column: "MessageContentId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "SysMessage");

            migrationBuilder.DropTable(
                name: "MessageContent");

            migrationBuilder.DropColumn(
                name: "FactoryNumbe",
                table: "ExperimentTask");

            migrationBuilder.UpdateData(
                table: "SysTenant",
                keyColumn: "Id",
                keyValue: 142307070918780L,
                column: "CreatedTime",
                value: new DateTime(2025, 1, 3, 15, 39, 9, 708, DateTimeKind.Local).AddTicks(423));

            migrationBuilder.UpdateData(
                table: "SysUser",
                keyColumn: "Id",
                keyValue: 142307070910551L,
                column: "CreatedTime",
                value: new DateTime(2025, 1, 3, 15, 39, 9, 709, DateTimeKind.Local).AddTicks(1625));

            migrationBuilder.UpdateData(
                table: "Team",
                keyColumn: "Id",
                keyValue: 242307070910559L,
                column: "CreatedTime",
                value: new DateTime(2025, 1, 3, 15, 39, 9, 800, DateTimeKind.Local).AddTicks(5445));
        }
    }
}
